import Router from 'koa-router';
import {deleteCollection} from '../chroma/index.js'
import {files} from '../db/models.js'
const delete_knowledge_base = new Router();

delete_knowledge_base.post('/', async (ctx) => {
    const { knowledge_base } = ctx.request.body;
    const res = await deleteCollection(knowledge_base)
    if(res === 'success'){
        await files.deleteMany({ knowledgeBase: knowledge_base });
        ctx.body = {
            code: 200,
            message: 'success'
        }
    }else {
        ctx.status = 500
        ctx.body = {
            code: 500,
            message: '删除失败'
        }
    }
})
export default delete_knowledge_base
